using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class web_Controls_cungcau_ntv_trinhdo : System.Web.UI.UserControl
{
    public Common comm = new Common();
    public DataTable dtt_main, dtt_sub;
    public string sql = "", sql_sub = "",sql_where="";
    protected void Page_Load(object sender, EventArgs e)
    {
        dtt_sub = comm.getDataTable("select banner_path from HeThong_config where id=4 or id=5");
        if (!string.IsNullOrEmpty(dtt_sub.Rows[0][0].ToString())){
            DateTime t1 = DateTime.ParseExact(dtt_sub.Rows[0][0].ToString().Split(';')[0].ToString(),"dd-MM-yyyy",null);
            DateTime t2 = DateTime.ParseExact(dtt_sub.Rows[0][0].ToString().Split(';')[1].ToString(),"dd-MM-yyyy",null);
            sql_where = " and D.ngay_dang_ky BETWEEN '" + t1.ToString("MM-dd-yyyy") + "' AND '" + t2.ToString("MM-dd-yyyy")+"' ";
        }
        if (!string.IsNullOrEmpty(dtt_sub.Rows[1][0].ToString()))
        {
            sql_where += " and D.ma_ho_so IN (select ma_ho_so_tim_viec from SanGiaoDich_nguoi_tim_viec where ma_san='"+
                dtt_sub.Rows[1][0].ToString()+"')";
        }
        sql = "SELECT B.ma_hoc_van,B.ten_hoc_van" +
            " FROM ConNguoi_hoc_van_chuyen_mon AS A INNER JOIN" +
            " DanhMuc_hoc_van AS B ON A.ma_hoc_van = B.ma_hoc_van INNER JOIN" +
            " ConNguoi_nguoi AS C ON C.ma_nguoi = A.ma_nguoi INNER JOIN" +
            " NguoiTimViec_ho_so AS D ON A.ma_nguoi = D.ma_nguoi" +
            " WHERE C.kich_hoat=1 and D.kich_hoat=1 "+sql_where+
            " GROUP BY B.ma_hoc_van,B.ten_hoc_van";
        dtt_main = comm.getDataTable(sql);
    }
}
